/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package dao.impl;

import dao.TheLoaiDAO;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.criterion.Expression;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import pojo.TheLoai;

/**
 *
 * @author pvhuy
 */
public class TheLoaiDAOImpl extends HibernateDaoSupport implements TheLoaiDAO{

    @Override
    public void saveTheLoai(TheLoai theLoai) {
        getHibernateTemplate().saveOrUpdate(theLoai);
    }

    @Override
    public List<TheLoai> listTheLoai() {
        return getHibernateTemplate().find("from TheLoai");
    }

    @Override
    public List<TheLoai> listTheLoaiByMaNhom(int nhomID) {
        Criteria crit = getSession().createCriteria(TheLoai.class);
        crit.add(Expression.eq("nhomSanPham.id", nhomID));
        return crit.list();
    }

}
